﻿@{
    ViewBag.Title = "AddFile";
    Layout = "~/Views/Shared/_LayoutChild.cshtml";
}
@model Agro.Models.T_File
@section head{
    <script type="text/javascript"
     src="@Url.Content("~/Scripts/jquery.uploadify-3.1.js")"  ></script>
    <link href="@Url.Content("~/Content/uploadify/uploadify.css")"     rel="stylesheet" type="text/css" />
    <style type="text/css">
        .uploadify-button
        {
            background-color: transparent;
            border: none;
            padding: 0;
        }
        .uploadify:hover .uploadify-button
        {
            background-color: transparent;
        }
        .uploadbtn
        {
            background: url(/content/upload.gif);
            width: 90px;
            height: 30px;
            background-color: transparent;
            border: none;
            padding: 0;
        }
        .uploadify-queue
        {
            position: absolute;
            left: 100px;
            top: 60px;
            width: 300px;
        }
        .b-col
        {
            width: 500px;
        }
        .col-input
        {
            width: 300px;
        }
        #File_Title
        {
            width: 300px;
        }
    </style>
    <script type="text/javascript">
        var thisframeid = "";
        $(document).ready(function () {
            initUpload();
        });
        function Save(t) {
          
            thisframeid = t;
            //先上传文件
            $('#btnImport').uploadify('upload');

        }
        function initUpload() {
            $("#btnImport").uploadify({
                'formData': { 'ASPSESSID': '@(Session.SessionID)', 'AUTHID': '@ViewBag.auth', GUID: '@ViewBag.GUID' },
                'multi': false,
                'auto': false, //设为true自动上传，false需要触发事件上传
                'swf': '/Content/uploadify/uploadify.swf',
                'uploader': '/FileManage/Upload/',
                'width': 90,
                'fileTypeExts': '*.*',
                'height': 22,
                'fileSizeLimit': '20480KB', //设置上传文件的大小20M
                'buttonImage': '/Content/import.gif',
                'queueSizeLimit': 1,
                'onUploadError': function (file, errorCode, errorMsg, errorString) {
                    parent.asyncbox.alert('文件上传失败:' + errorString, '提示');
                    parent.$.cover(false);
                    hideparentloading();
                },
                'onUploadStart': function (file) {//开始上传事件
                    showparentloading();
                    parent.$.cover(true);
                },

                'onUploadSuccess': function (file, data, response) {
                    if (response) {
                        var json = eval(data);
                        $("#File_Title").val(json[0].filename);
                        $("#File_ServerName").val(json[0].savefilename); //源文件名称
                        $("#File_Type").val(json[0].fileExtension); //文件类型
                        //保存标题内容
                        $.funSaveForm("/FileManage/File/SaveFile", "formDetail", function (d) {
                            $("#File_ID").val(d);
                            parent.asyncbox.tips('保存成功!', 'success');
                            MainFrame().$(MainFrame().gridId).trigger("reloadGrid");
                            parent.$.close(thisframeid.id);
                        });
                    }
                    else {
                        parent.asyncbox.alert('保存失败!', '提示');
                    }

                    parent.$.cover(false);
                    hideparentloading();
                }
            });
        }
    </script>
}
<!--主窗体，页面都需要的div-->
<div id="divGridContainer" class="ui-layout-center" style="overflow: auto;">
    @using (Html.BeginForm("", "", FormMethod.Post, new Dictionary<string, object> { { "id", "formDetail" } }))
    {
        @Html.HiddenFor(model => model.File_ID)
        @Html.HiddenFor(model => model.File_Type)
        <div class='b-col'>
            <div class="col-name">
                文件名称：</div>
            <div class="col-input">@Html.TextBoxFor(model => model.File_Title)</div>
        </div>
        <div class='b-col'>
            <div class="col-name">
                系统名称：</div>
            <div class="col-input">@Html.TextBoxFor(model => model.File_ServerName)</div>
        </div>
        <div class='b-col'>
            <div class="col-name">
                选择文件：</div>
            <div class="col-input">
                <input type="file" name="btnImport" id="btnImport" /></div>
            <div>
            </div>
        </div>
    }
</div>
